package com.dao;

import com.po.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookDao {
    //查询所有图书
    @Select("select id, type, name, description from tbl_book")
    List<Book> findAll();

    //根据Id查询图书
    @Select("select id, type, name, description from tbl_book where id = #{id}")
    Book findById(Integer id);

    //添加图书
    @Insert("insert into tbl_book (type, name, description) values (#{type},#{name},#{description})")
    Integer save(Book book);

    //编辑图书
    @Update("update tbl_book set type = #{type}, name = #{name}, description = #{description} where id = #{id}")
    Integer update(Book book);

    //删除图书
    @Delete("delete from tbl_book where id = #{id}")
    Integer delete(Integer id);

}
